package me.helllp.bootman.back.logic.system.web;

import javax.validation.Valid;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import me.helllp.bootman.back.logic.system.services.UserService;
import me.helllp.bootman.back.logic.system.services.impl.BackUserService;
import me.helllp.bootman.back.logic.system.vo.User001Input;
import me.helllp.bootman.common.base.BaseController;
import me.helllp.bootman.common.base.BaseReturn;
import me.helllp.bootman.common.services.LoginUserServices;

@RestController
@RequestMapping("/user")
@Api("用户信息管理") 
public class UserController extends BaseController{
	private static final Logger logger = LoggerFactory.getLogger(UserController.class);
	
	@Autowired
	private UserService userService;
	
	@ApiOperation("登录功能")
	@PostMapping("/no001")
	public BaseReturn logicUser001(@Valid @RequestBody User001Input input, BindingResult result){
		if (result.hasErrors()) {
			BaseReturn ret = this.genCheckResult(result);
			logger.info(ret.toString());
			return ret;
		}	
		
		return userService.logicUser001(input);
	}
	
	@ApiOperation("退出功能")
	@PostMapping("/no002")
	public BaseReturn logoutUser002(){
		return userService.logicUser002();
	}

	@Autowired
	private BackUserService backService;
	
	@GetMapping("/test")
	public BaseReturn logout(){
		return this.genSuccesResult(backService.findRoles(173128036923871232L));
	}
}
